Data stored in database systems often is accessed by users who provide queries defining the type of information that they would like to receive. For example, a query in a database that contains employee information could define a range of dates and request information on all employees who started to work for the company in the specified time range. Often, there are a large number of possible approaches that will each produce the information requested by the query. Each approach involves a series of database access steps. For example, a query seeking the last names of all employees who sold more than 100 products in a particular month could require information from different tables stored in the database. One table that includes a record for each product sold including the employee number of the person that sold it could be used to determine the employee numbers with more than 100 sales. Another table could be used to determine the last name that corresponds to each of those employee numbers. The time and system resources expended to provide the query answer can depend on the order in which those steps are performed.
One conventional way to choose the order in which steps will be performed to execute a database query includes estimating the time and system resources that will be necessary for each possible series of steps. The series of steps with the lowest cost can then be selected. Data to be retrieved or manipulated by a step is often chosen in accordance with conditions. For example, retrieving data regarding a certain employee might involve using a condition that the employee_number field be equal to the employee's actual number. Other examples of conditions include a comparison condition, e.g., all employees who started before a particular date, or a range condition, e.g., all products costing between $19 and $99. The database system can determine the conditions corresponding to a step based on the query and the analysis of that query. The database system employees those conditions both to estimate the cost of a particular series of steps and to actually carry out the series of steps chosen to execute the query.